package cn.topevery.garden.framework.config;

import cn.topevery.garden.framework.util.KeyUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.security.KeyPair;


@Component
public class RsaKeyCache {

    static KeyPair rsaKey;

    @Autowired(required = false)
    RsaKeyProperties rsaKeyProperties;

    @PostConstruct
    void init() {
        rsaKey = KeyUtils.generateRsaKey(rsaKeyProperties);
    }

    public static KeyPair getRsaKey() {
        return rsaKey;
    }
}
